package com.zzh.lib.views.state.empty;

import android.widget.Adapter;
import android.widget.AdapterView;

import com.zzh.lib.views.def.ICountAdapter;


public class AdapterViewEmptyStrategy extends SourceCountEmptyStrategy<AdapterView> {
    public AdapterViewEmptyStrategy(AdapterView source) {
        super(source);
    }

    public AdapterViewEmptyStrategy(AdapterView source, int emptyCount) {
        super(source, emptyCount);
    }

    @Override
    protected int getCount() {
        final Adapter adapter = getSource().getAdapter();
        if (adapter == null)
            return -1;

        if (adapter instanceof ICountAdapter) {
            return ((ICountAdapter) adapter).getItemRealCount();
        }

        return adapter.getCount();
    }
}
